package com.witframework.meta.validator;

import java.text.ParseException;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

import org.apache.commons.lang.StringUtils;

import com.witframework.util.DateUtil;


public class TimeStampValidator implements ConstraintValidator<TimeStampStr, String> {

	public void initialize(TimeStampStr arg0) {
	}

	public boolean isValid(String str, ConstraintValidatorContext arg1) {
		if(StringUtils.isEmpty(str)){
			return false;
		}
		try {
			DateUtil.convertStringToDate("yyyy-MM-dd HH:mm",str);
			return true;
		} catch (ParseException e) {
			return false;
		}
	}

}
